
package com.afd.ozblip.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import com.afd.ozblip.entity.ActivityEntity;
import com.afd.ozblip.entity.BusinessCouponEntity;
import com.afd.ozblip.entity.BusinessEntity;
import com.afd.ozblip.entity.BusinessPhotoEntity;
import com.afd.ozblip.entity.CityEntity;
import com.afd.ozblip.entity.CouponEntity;
import com.afd.ozblip.entity.DishEntity;
import com.afd.ozblip.entity.RecDishEntity;
import com.afd.ozblip.entity.ReviewEntity;
import com.afd.ozblip.entity.SignEntity;
import com.afd.ozblip.entity.UserEntity;
import com.afd.ozblip.entity.UserIntegralEntity;
import com.afd.ozblip.entity.UserIntegralResult;
import com.afd.ozblip.entity.VipEntity;

public class ParseJson {

    // *************************解析相同格式数据***************************//
    /**
     * 解析添加返回结果JSON数据
     * 
     * @param resultByte
     * @return
     */
    public Map<String, Object> parseAddResultJson(byte[] resultByte) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        JSONObject resultJson = null;
        String msg = "无";
        try {
            resultJson = new JSONObject(new String(resultByte, "UTF-8"));
            resultMap.put("returnFlg", resultJson.getBoolean("returnFlg"));
            resultMap.put("regMessage", resultJson.getString("regMessage"));
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return resultMap;
    }

    // TODO 商家模版数据解析
    // *************************商家模版数据解析***************************//
    /**
     * 解析商家列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public Map<String, Object> parseBusinessListJson(byte[] resultByte) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        JSONObject resultJson = null;
        ArrayList<BusinessEntity> businessList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            resultJson = new JSONObject(new String(resultByte, "UTF-8"));
            jsonArray = resultJson.getJSONArray("data");
            businessList = new ArrayList<BusinessEntity>();
            for (int i = 0, len = jsonArray.length(); i < len; i++) {
                JSONObject busienssJson = jsonArray.getJSONObject(i);
                BusinessEntity business = new BusinessEntity();
                business.setSellerName(busienssJson.getString("sellerName"));
                business.setSellerId(busienssJson.getString("sellerId"));
                business.setSellerImg(busienssJson.getString("sellerImg"));
                business.setSellerTel(busienssJson.getString("sellerTel"));
                business.setSellerAddress(busienssJson
                        .getString("sellerAddress"));
                business.setSellerLongitude(busienssJson
                        .getString("sellerLongitude"));
                business.setSellerDimension(busienssJson
                        .getString("sellerDimension"));
                business.setCouponFlg(busienssJson.getBoolean("couponFlg"));
                business.setMemberCardFlg(busienssJson
                        .getBoolean("memberCardFlg"));
                if (!StringUtil.isNullOrEmpty(busienssJson
                        .getString("sellerStar"))) {
                    business.setSellerStar(Float.valueOf(busienssJson
                            .getString("sellerStar")));
                } else {
                    business.setSellerStar(0.0f);
                }
                if (!StringUtil.isNullOrEmpty(busienssJson.getString("price"))) {
                    business.setPrice(busienssJson.getString("price"));
                } else {
                    business.setPrice("0");
                }
                business.setDistance(busienssJson.getString("distance"));
                businessList.add(business);
            }
            resultMap.put("data", businessList);
            if (resultJson.has("totalPage")) {
                resultMap.put("totalPage", resultJson.getInt("totalPage"));
            } else {
                resultMap.put("totalPage", 0);
            }

        } catch (Exception e) {
            e.printStackTrace();
            resultMap.put("data", businessList);
            resultMap.put("totalPage", 0);
            System.out.println(msg);
        }
        return resultMap;
    }

    /**
     * 解析商家详情JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public BusinessEntity parseBusinessInfoJson(byte[] resultByte) {
        JSONObject busienssJson = null;
        BusinessEntity business = null;
        String msg = "无";
        try {
            busienssJson = new JSONObject(new String(resultByte, "UTF-8"));
            business = new BusinessEntity();
            business.setSellerName(busienssJson.getString("sellerName"));
            business.setSellerId(busienssJson.getString("sellerId"));
            business.setSellerImg(busienssJson.getString("sellerImg"));
            business.setSellerTel(busienssJson.getString("sellerTel"));
            business.setSellerAddress(busienssJson.getString("sellerAddress"));
            business.setSellerLongitude(busienssJson
                    .getString("sellerLongitude"));
            business.setSellerDimension(busienssJson
                    .getString("sellerDimension"));
            // business.setCouponFlg(busienssJson.getBoolean("couponFlg"));
            // business.setMemberCardFlg(busienssJson.getBoolean("memberCardFlg"));
            // 所属小类
            if (busienssJson.has("chiClass")) {
                business.setChiClass(busienssJson.getString("chiClass"));
            }
            // 所属大类
            if (busienssJson.has("parClass")) {
                business.setParClass(busienssJson.getString("parClass"));
            }
            // 口味，环境，服务
            business.setRicPoint(busienssJson.getDouble("ricPoint"));
            business.setThrPoint(busienssJson.getDouble("thrPoint"));
            business.setEnvPoint(busienssJson.getDouble("envPoint"));
            // 商户其它信息
            business.setOtherInfo(busienssJson.getString("otherInfo"));
            if (!StringUtil.isNullOrEmpty(busienssJson.getString("sellerStar"))) {
                business.setSellerStar(Float.valueOf(busienssJson
                        .getString("sellerStar")));
            } else {
                business.setSellerStar(0.0f);
            }
            if (!StringUtil.isNullOrEmpty(busienssJson.getString("price"))) {
                business.setPrice(busienssJson.getString("price"));
            } else {
                business.setPrice("0");
            }
            String couponJsonStr = busienssJson.getString("newCouponInfo");
            if (!StringUtil.isNullOrEmpty(couponJsonStr)) {
                JSONObject couponJson = new JSONObject(couponJsonStr);
                BusinessCouponEntity bce = new BusinessCouponEntity();
                bce.setCouponId(couponJson.getString("couponId"));
                bce.setCouponTitle(couponJson.getString("title"));
                bce.setCouponNaiyo(couponJson.getString("content"));
                bce.setCouponTo(couponJson.getString("lifeDate"));
                business.setNewsCoupon(bce);
            }
            if (busienssJson.has("recommedDish")) {
                JSONArray dishJsonArray = busienssJson
                        .getJSONArray("recommedDish");
                List<DishEntity> dishList = new ArrayList<DishEntity>();
                for (int i = 0, dishLen = dishJsonArray.length(); i < dishLen; i++) {
                    JSONObject dishJson = dishJsonArray.getJSONObject(i);
                    DishEntity dish = new DishEntity();
                    dish.setDishId(dishJson.getString("DishId"));
                    dish.setDishName(dishJson.getString("DishName"));
                    dishList.add(dish);
                }
                business.setRecommendDish(dishList);
                business.setRecDishCount(busienssJson.getInt("recDishCount"));
            }
            String reviewJsonStr = busienssJson.getString("sellerTalkInfo");
            if (!StringUtil.isNullOrEmpty(reviewJsonStr)) {
                JSONObject reviewJson = new JSONObject(reviewJsonStr);
                ReviewEntity review = new ReviewEntity();
                review.setUserName(reviewJson.getString("nickName"));
                review.setSellerStar(Float.valueOf(reviewJson
                        .getString("sellerStar")));
                review.setReviewDate(reviewJson.getString("reviewDate"));
                review.setReviewNaiyo(reviewJson.getString("reviewNaiyo"));
                business.setSellerTalkInfo(review);
            }
            // 签到人数
            if (busienssJson.has("sginCnt")) {
                business.setSginCnt(busienssJson.getInt("sginCnt"));
            }
            String signJsonStr = busienssJson.getString("sellerPoint");
            if (!StringUtil.isNullOrEmpty(signJsonStr)) {
                JSONObject signJson = new JSONObject(signJsonStr);
                SignEntity sign = new SignEntity();
                sign.setUserName(signJson.getString("userName"));
                sign.setSellerStar(Float.valueOf(signJson.getString("signStar")));
                sign.setSginDate(signJson.getString("signTime"));
                sign.setSginImg(signJson.getString("signImageUrl"));
                sign.setSginNaiyo(signJson.getString("signContent"));
                business.setSellerPoint(sign);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return business;
    }

    /**
     * 解析商家菜单列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<DishEntity> parseBusinessDishListJson(byte[] resultByte) {
        List<DishEntity> dishList = null;
        JSONArray dishJsonArray = null;
        String msg = "无";
        try {
            dishJsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            dishList = new ArrayList<DishEntity>();
            for (int i = 0, dishLen = dishJsonArray.length(); i < dishLen; i++) {
                JSONObject dishJson = dishJsonArray.getJSONObject(i);
                DishEntity dish = new DishEntity();
                dish.setDishId(dishJson.getString("dishId"));
                dish.setDishName(dishJson.getString("dishName"));
                // dish.setDishPoint(dishJson.getInt("dishPoint"));
                dish.setDishImg(dishJson.getString("dishImg"));
                dish.setDishType(dishJson.getString("statusOth"));
                dish.setDishPrice(dishJson.getString("dishprice"));
                dishList.add(dish);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return dishList;
    }

    /**
     * 解析商家推荐菜单列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<RecDishEntity> parseBusinessRecDishListJson(byte[] resultByte) {
        List<RecDishEntity> recList = null;
        JSONArray recJsonArray = null;
        String msg = "无";
        try {
            recJsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            recList = new ArrayList<RecDishEntity>();
            for (int i = 0, dishLen = recJsonArray.length(); i < dishLen; i++) {
                JSONObject recJson = recJsonArray.getJSONObject(i);
                RecDishEntity rd = new RecDishEntity();
                rd.setBusinessName(recJson.getString("sellerName"));
                rd.setRecDishBigImageUrl(recJson.getString("bigImageUrl"));
                rd.setRecDishSmallImageUrl(recJson.getString("smallImageUrl"));
                rd.setDishName(recJson.getString("dishName"));
                rd.setRecNums(recJson.getInt("recNums"));
                rd.setRecTime(recJson.getString("recTime"));
                rd.setDishPrice(recJson.getString("recPrice"));
                rd.setRecUserName(recJson.getString("recUserName"));
                rd.setRecStar(Float.valueOf(recJson.getString("recStar")));
                recList.add(rd);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return recList;
    }

    /**
     * 解析商家照片列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<BusinessPhotoEntity> parseBusinessPhotoListJson(
            byte[] resultByte) {
        List<BusinessPhotoEntity> photoList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            photoList = new ArrayList<BusinessPhotoEntity>();
            for (int i = 0, dishLen = jsonArray.length(); i < dishLen; i++) {
                JSONObject photoJson = jsonArray.getJSONObject(i);
                BusinessPhotoEntity photo = new BusinessPhotoEntity();
                photo.setImgMinUrl(photoJson.getString("imgMinUrl"));
                photo.setImgMaxUrl(photoJson.getString("imgMaxUrl"));
                photo.setImgTitle(photoJson.getString("imgTitle"));
                photoList.add(photo);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return photoList;
    }

    /**
     * 解析商家点评列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<ReviewEntity> parseBusinessReviewListJson(byte[] resultByte) {
        List<ReviewEntity> reviewList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            reviewList = new ArrayList<ReviewEntity>();
            for (int i = 0, reviewLen = jsonArray.length(); i < reviewLen; i++) {
                JSONObject reviewJson = jsonArray.getJSONObject(i);
                ReviewEntity review = new ReviewEntity();
                review.setUserName(reviewJson.getString("sellerName"));
                review.setSellerStar(Float.valueOf(reviewJson
                        .getString("sellerStar")));
                review.setPrice(reviewJson.getString("price"));
                review.setReviewDate(reviewJson.getString("reviewDate"));
                review.setReviewNaiyo(reviewJson.getString("reviewNaiyo"));
                reviewList.add(review);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return reviewList;
    }

    /**
     * 解析商家点评列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<SignEntity> parseBusinessSignListJson(byte[] resultByte) {
        List<SignEntity> signList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            signList = new ArrayList<SignEntity>();
            for (int i = 0, signLen = jsonArray.length(); i < signLen; i++) {
                JSONObject photoJson = jsonArray.getJSONObject(i);
                SignEntity sign = new SignEntity();
                sign.setUserName(photoJson.getString("userName"));
                sign.setSellerStar(Float.valueOf(photoJson
                        .getString("sellerStar")));
                sign.setSginDate(photoJson.getString("sginDate"));
                // sign.setSginImg(photoJson.getString("sginImg"));
                sign.setSginNaiyo(photoJson.getString("sginNaiyo"));
                signList.add(sign);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return signList;
    }

    /**
     * 解析商家优惠券列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<CouponEntity> parseBusinessCouponListJson(byte[] resultByte) {
        List<CouponEntity> signList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            signList = new ArrayList<CouponEntity>();
            for (int i = 0, signLen = jsonArray.length(); i < signLen; i++) {
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                CouponEntity coupon = new CouponEntity();
                coupon.setBusinessImageUrl(jsonObj.getString("sellerImg"));
                coupon.setBusinessName(jsonObj.getString("sellerName"));
                coupon.setCouponTitle(jsonObj.getString("couponTitle"));
                coupon.setCouponContent(jsonObj.getString("couponContent"));
                coupon.setLiftDate(jsonObj.getString("lifeDate"));
                coupon.setCouponId(jsonObj.getString("couponId"));
                coupon.setBusinessArea(jsonObj.getString("areaName"));
                coupon.setBusinessAddress(jsonObj.getString("sellerAddress"));
                coupon.setBusinessType(jsonObj.getString("chiName"));
                coupon.setCouponDownloadCount(jsonObj
                        .getString("downloadTimes"));
                signList.add(coupon);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return signList;
    }

    /**
     * 解析优惠券适用商家列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<BusinessEntity> parseCouponBusinessListJson(byte[] resultByte) {
        List<BusinessEntity> signList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            signList = new ArrayList<BusinessEntity>();
            for (int i = 0, signLen = jsonArray.length(); i < signLen; i++) {
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                BusinessEntity business = new BusinessEntity();
                business.setSellerId(jsonObj.getString("sellerId"));
                business.setSellerName(jsonObj.getString("sellerName"));
                business.setSellerAddress(jsonObj.getString("sellerAddress"));
                business.setOtherInfo(jsonObj.getString("sellerNear"));
                business.setSellerLongitude(jsonObj
                        .getString("sellerLongitude"));
                business.setSellerDimension(jsonObj
                        .getString("sellerDimension"));
                signList.add(business);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return signList;
    }

    /**
     * 解析商家会员卡列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<VipEntity> parseBusinessVipListJson(byte[] resultByte) {
        List<VipEntity> vipList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            vipList = new ArrayList<VipEntity>();
            for (int i = 0, signLen = jsonArray.length(); i < signLen; i++) {
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                VipEntity vip = new VipEntity();
                vip.setBusinessId(jsonObj.getString("sellerId"));
                vip.setBusinessName(jsonObj.getString("sellerName"));
                vip.setVipId(jsonObj.getString("vipId"));
                // vip.setVipUserName(jsonObj.getString("vipName"));
                vip.setVipTitle(jsonObj.getString("vipTitle"));
                vip.setVipContent(jsonObj.getString("vipContent"));
                vip.setBusinessArea(jsonObj.getString("areaName"));
                Double distance = jsonObj.getDouble("distance");
                vip.setBusinessDistance(String.valueOf(distance.intValue()));
                // vip.setSellerOtherName(jsonObj.getString("sellerOtherName"));
                vipList.add(vip);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return vipList;
    }

    /**
     * 解析商家活动列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<ActivityEntity> parseBusinessActivityListJson(byte[] resultByte) {
        List<ActivityEntity> activityList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            activityList = new ArrayList<ActivityEntity>();
            for (int i = 0, signLen = jsonArray.length(); i < signLen; i++) {
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                ActivityEntity vip = new ActivityEntity();
                vip.setSellerId(jsonObj.getString("sellerId"));
                vip.setActivityImageUrl(jsonObj.getString("ActivitiesImg"));
                vip.setActivityTitle(jsonObj.getString("ActivitiesTitle"));
                vip.setActivityEndTime(jsonObj.getString("ActivitiesToDate"));
                vip.setActivityContent(jsonObj.getString("ActivitiesNaiyo"));
                activityList.add(vip);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return activityList;
    }

    // TODO 用户模版数据解析
    // *************************用户模版数据解析***************************//
    /**
     * 解析注册返回结果JSON数据
     * 
     * @param resultByte
     * @return
     */
    public Map<String, Object> parseRegisterRsJson(byte[] resultByte) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        JSONObject resultJson = null;
        String msg = "无";
        try {
            resultJson = new JSONObject(new String(resultByte, "UTF-8"));
            resultMap.put("returnFlg", resultJson.getBoolean("returnFlg"));
            String userJsonStr = resultJson.getString("userInfo");
            JSONObject userJson = new JSONObject(userJsonStr);
            UserEntity userInfo = new UserEntity();
            if (userJson.has("userId")) {
                userInfo.setUserId(userJson.getString("userId"));
                if (userJson.has("email")) {
                    userInfo.setUserEmail(userJson.getString("email"));
                }
                if (userJson.has("headImgUrl")) {
                    userInfo.setUserHeadUrl(userJson.getString("headImgUrl"));
                }
                if (userJson.has("realName")) {
                    userInfo.setUserName(userJson.getString("realName"));
                }
                if (userJson.has("nickName")) {
                    userInfo.setUserNickName(userJson.getString("nickName"));
                }
                if (userJson.has("rePoint")) {
                    userInfo.setUserIntegral(userJson.getString("rePoint"));
                }
                if (userJson.has("userlevel")) {
                    userInfo.setUserLevel(userJson.getString("userlevel"));
                }
                if (userJson.has("sex")) {
                    userInfo.setUserSex(userJson.getString("sex"));
                }
                if (userJson.has("age")) {
                    userInfo.setUserAge(userJson.getString("age"));
                }
                if (userJson.has("career")) {
                    userInfo.setUserCareer(userJson.getString("career"));
                }
                if (userJson.has("telphone")) {
                    userInfo.setUserTelephone(userJson.getString("telphone"));
                }
                if (userJson.has("signature")) {
                    userInfo.setUserSignature(userJson.getString("signature"));
                }
            }
            resultMap.put("userInfo", userInfo);
            resultMap.put("regMessage", resultJson.getString("regMessage"));
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return resultMap;
    }

    /**
     * 解析用户详情JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public UserEntity parseUserInfoJson(byte[] resultByte) {
        JSONObject loginJson = null;
        UserEntity userInfo = null;
        String msg = "无";
        try {
            loginJson = new JSONObject(new String(resultByte, "UTF-8"));
            userInfo = new UserEntity();
            userInfo.setLogintResult(loginJson.getBoolean("loginResult"));
            userInfo.setLoginMessage(loginJson.getString("loginMessage"));
            JSONObject userJson = new JSONObject(
                    loginJson.getString("userInfo"));
            if (userJson.has("userId")) {
                userInfo.setUserId(userJson.getString("userId"));
                if (userJson.has("email")) {
                    userInfo.setUserEmail(userJson.getString("email"));
                }
                if (userJson.has("headImgUrl")) {
                    userInfo.setUserHeadUrl(userJson.getString("headImgUrl"));
                }
                if (userJson.has("realName")) {
                    userInfo.setUserName(userJson.getString("realName"));
                }
                if (userJson.has("nickName")) {
                    userInfo.setUserNickName(userJson.getString("nickName"));
                }
                if (userJson.has("rePoint")) {
                    userInfo.setUserIntegral(userJson.getString("rePoint"));
                }
                if (userJson.has("userlevel")) {
                    userInfo.setUserLevel(userJson.getString("userlevel"));
                }
                if (userJson.has("sex")) {
                    userInfo.setUserSex(userJson.getString("sex"));
                }
                if (userJson.has("age")) {
                    userInfo.setUserAge(userJson.getString("age"));
                }
                if (userJson.has("career")) {
                    userInfo.setUserCareer(userJson.getString("career"));
                }
                if (userJson.has("telphone")) {
                    userInfo.setUserTelephone(userJson.getString("telphone"));
                }
                if (userJson.has("signature")) {
                    userInfo.setUserSignature(userJson.getString("signature"));
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return userInfo;
    }

    /**
     * 解析商家会员卡列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<VipEntity> parseUserVipListJson(byte[] resultByte) {
        List<VipEntity> vipList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            vipList = new ArrayList<VipEntity>();
            for (int i = 0, signLen = jsonArray.length(); i < signLen; i++) {
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                VipEntity vip = new VipEntity();
                vip.setBusinessId(jsonObj.getString("sellerId"));
                vip.setBusinessName(jsonObj.getString("sellerName"));
                vip.setVipId(jsonObj.getString("vipId"));
                vip.setVipUserName(jsonObj.getString("vipName"));
                vip.setVipTitle(jsonObj.getString("vipDiscount"));
                vip.setVipContent(jsonObj.getString("vipDisNaiyo"));
                // vip.setSellerOtherName(jsonObj.getString("sellerOtherName"));
                vipList.add(vip);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return vipList;
    }

    /**
     * 解析附近用户列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<UserEntity> parsePeopleListJson(byte[] resultByte) {
        JSONArray userJsonArray = null;
        List<UserEntity> userList = null;
        String msg = "无";
        try {
            userJsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            userList = new ArrayList<UserEntity>();
            for (int i = 0, len = userJsonArray.length(); i < len; i++) {
                JSONObject userJson = userJsonArray.getJSONObject(i);
                UserEntity user = new UserEntity();
                user.setUserId(userJson.getString("userId"));
                user.setUserNickName(userJson.getString("userName"));
                if (userJson.has("userImageUrl")) {
                    user.setUserHeadUrl(userJson.getString("userImageUrl"));
                }
                user.setUserLevel(userJson.getString("userLevel"));
                user.setUserIntegral(userJson.getString("userIntegral"));
                user.setUserSignature(userJson.getString("userSignature"));
                userList.add(user);
            }

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return userList;
    }

    /**
     * 解析用户详情JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<UserEntity> parseUserFriendListJson(byte[] resultByte) {
        JSONArray userJsonArray = null;
        List<UserEntity> userList = null;
        String msg = "无";
        try {
            userJsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            userList = new ArrayList<UserEntity>();
            for (int i = 0, len = userJsonArray.length(); i < len; i++) {
                JSONObject userJson = userJsonArray.getJSONObject(i);
                UserEntity user = new UserEntity();
                user.setUserId(userJson.getString("userId"));
                user.setUserNickName(userJson.getString("userNickName"));
                user.setUserName(userJson.getString("userNickName"));
                if (userJson.has("userImageUrl")) {
                    user.setUserHeadUrl(userJson.getString("userImageUrl"));
                }
                user.setUserNickNameJM(userJson.getString("userNickNameJM"));
                userList.add(user);
            }

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return userList;
    }

    /**
     * 解析用户优惠券列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<CouponEntity> parseUserCouponListJson(byte[] resultByte) {
        List<CouponEntity> signList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            signList = new ArrayList<CouponEntity>();
            for (int i = 0, signLen = jsonArray.length(); i < signLen; i++) {
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                CouponEntity coupon = new CouponEntity();
                coupon.setBusinessImageUrl(jsonObj.getString("sellerMinImgUrl"));
                coupon.setBusinessName(jsonObj.getString("sellerName"));
                coupon.setCouponTitle(jsonObj.getString("couponTitle"));
                coupon.setCouponContent(jsonObj.getString("couponContent"));
                coupon.setLiftDate(jsonObj.getString("lifeDate"));
                coupon.setCouponId(jsonObj.getString("couponId"));
                coupon.setBusinessArea(jsonObj.getString("sellerArea"));
                coupon.setBusinessType(jsonObj.getString("chiClass"));
                signList.add(coupon);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return signList;
    }

    /**
     * 解析商家点评列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<ReviewEntity> parseUserReviewListJson(byte[] resultByte) {
        List<ReviewEntity> reviewList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            reviewList = new ArrayList<ReviewEntity>();
            for (int i = 0, reviewLen = jsonArray.length(); i < reviewLen; i++) {
                JSONObject reviewJson = jsonArray.getJSONObject(i);
                ReviewEntity review = new ReviewEntity();
                review.setUserName(reviewJson.getString("sellerName"));
                review.setSellerStar(Float.valueOf(reviewJson
                        .getString("sellerStar")));
                review.setReviewDate(reviewJson.getString("reviewDate"));
                review.setReviewNaiyo(reviewJson.getString("sellerNaiyo"));
                reviewList.add(review);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return reviewList;
    }

    /**
     * 解析用户图片列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<RecDishEntity> parseUserPhotoListJson(byte[] resultByte) {
        List<RecDishEntity> recList = null;
        JSONArray recJsonArray = null;
        String msg = "无";
        try {
            recJsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            recList = new ArrayList<RecDishEntity>();
            for (int i = 0, dishLen = recJsonArray.length(); i < dishLen; i++) {
                JSONObject recJson = recJsonArray.getJSONObject(i);
                RecDishEntity rd = new RecDishEntity();
                rd.setBusinessName(recJson.getString("sellerName"));
                rd.setRecDishBigImageUrl(recJson.getString("recBigImg"));
                rd.setRecDishSmallImageUrl(recJson.getString("uploadImg"));
                rd.setRecTime(recJson.getString("uploadDate"));
                recList.add(rd);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return recList;
    }

    /**
     * 解析商家会员卡列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public UserIntegralResult parseUserIntegralListJson(byte[] resultByte) {
        UserIntegralResult uir = new UserIntegralResult();
        List<UserIntegralEntity> integralList = null;
        JSONArray jsonArray = null;
        String msg = "无";
        try {
            JSONObject resultObj = new JSONObject(new String(resultByte,
                    "UTF-8"));
            uir.setUserLevel(resultObj.getString("userLevel"));
            uir.setUserBadge(resultObj.getString("userBadge"));
            uir.setUserPoint(resultObj.getString("userPoint"));
            jsonArray = resultObj.getJSONArray("userPointMin");
            integralList = new ArrayList<UserIntegralEntity>();
            for (int i = 0, signLen = jsonArray.length(); i < signLen; i++) {
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                UserIntegralEntity integral = new UserIntegralEntity();
                integral.setIntegralTitle(jsonObj.getString("userPointTitle"));
                integral.setIntegralVal(jsonObj.getString("MinPoint"));
                integralList.add(integral);
            }
            uir.setUserPointMin(integralList);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return uir;
    }

    /**
     * 解析用户收藏商家JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public ArrayList<BusinessEntity> parseUserCollectListJson(byte[] resultByte) {
        ArrayList<BusinessEntity> businessList = null;
        JSONArray jsonArray = null;
        // String msg = "无";
        try {
            jsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            businessList = new ArrayList<BusinessEntity>();
            for (int i = 0, len = jsonArray.length(); i < len; i++) {
                JSONObject busienssJson = jsonArray.getJSONObject(i);
                BusinessEntity business = new BusinessEntity();
                business.setSellerName(busienssJson.getString("sellerName"));
                business.setSellerId(busienssJson.getString("sellerId"));
                business.setSellerImg(busienssJson.getString("sellerImg"));
                business.setSellerTel(busienssJson.getString("sellerTel"));
                business.setSellerAddress(busienssJson
                        .getString("sellerAddress"));
                business.setSellerLongitude(busienssJson
                        .getString("sellerLongitude"));
                business.setSellerDimension(busienssJson
                        .getString("sellerDimension"));
                business.setCouponFlg(busienssJson.getBoolean("couponFlg"));
                business.setMemberCardFlg(busienssJson
                        .getBoolean("memberCardFlg"));
                if (busienssJson.has("sellerStar")
                        && !StringUtil.isNullOrEmpty(busienssJson
                                .getString("sellerStar"))) {
                    business.setSellerStar(Float.valueOf(busienssJson
                            .getString("sellerStar")));
                } else {
                    business.setSellerStar(0.0f);
                }
                if (busienssJson.has("price")
                        && !StringUtil.isNullOrEmpty(busienssJson
                                .getString("price"))) {
                    business.setPrice(busienssJson.getString("price"));
                } else {
                    business.setPrice("0");
                }
                business.setDistance(busienssJson.getString("distance"));
                businessList.add(business);
            }

        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        return businessList;
    }

    // TODO 公共模版数据解析
    // *************************公共模版数据解析***************************//
    /**
     * 解析城市列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<HashMap<String, Object>> parseCityListJson(byte[] resultByte) {
        List<HashMap<String, Object>> recList = null;
        JSONArray recJsonArray = null;
        String msg = "无";
        try {
            recJsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            recList = new ArrayList<HashMap<String, Object>>();
            for (int i = 0, dishLen = recJsonArray.length(); i < dishLen; i++) {
                JSONObject recJson = recJsonArray.getJSONObject(i);
                HashMap<String, Object> rd = new HashMap<String, Object>();
                rd.put("cityId", recJson.getString("cityId"));
                rd.put("cityName", recJson.getString("cityName"));
                recList.add(rd);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return recList;
    }

    /**
     * 解析城市列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<CityEntity> parseCityListJson2(byte[] resultByte) {
        List<CityEntity> recList = null;
        JSONArray recJsonArray = null;
        String msg = "无";
        try {
            recJsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            recList = new ArrayList<CityEntity>();
            for (int i = 0, dishLen = recJsonArray.length(); i < dishLen; i++) {
                JSONObject recJson = recJsonArray.getJSONObject(i);
                CityEntity city = new CityEntity();
                city.setCityId(recJson.getString("cityId"));
                city.setCityName(recJson.getString("cityName"));
                city.setNameSort(recJson.getString("cityNamePinyin")
                        .substring(0, 1).toUpperCase());
                recList.add(city);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return recList;
    }

    /**
     * 解析区域列表JSON数据
     * 
     * @param resultByte 数据字节
     * @return
     */
    public List<HashMap<String, Object>> parseAreaListJson(byte[] resultByte) {
        List<HashMap<String, Object>> recList = null;
        JSONArray recJsonArray = null;
        String msg = "无";
        try {
            recJsonArray = new JSONArray(new String(resultByte, "UTF-8"));
            recList = new ArrayList<HashMap<String, Object>>();
            for (int i = 0, dishLen = recJsonArray.length(); i < dishLen; i++) {
                JSONObject recJson = recJsonArray.getJSONObject(i);
                HashMap<String, Object> rd = new HashMap<String, Object>();
                rd.put("areaId", recJson.getString("areaId"));
                rd.put("areaName", recJson.getString("areaName"));
                recList.add(rd);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println(msg);
        }
        return recList;
    }
}
